# 字符串
# e = "hello world"
# #列表
#
# #数据类型
# info1 = {"a1":112,"a2":"test","a3":[1,2,3,4,5],"a4":(2,3,4,5),"a5":{3,5,6,7}}
# print(info1)
#
# #数字类型
# num1 = 12
# num2 = 1.76
# num3 = True
# #知道上面变量的数据类型，通过print（对象）
# print(type(num1))
# print(type(num2))
# print(type(num3))
# a1="abc"
# a2=[11,"张三",1.11]
# a3=(11,"张三",1.11)
# a4={11,"张三",1.11}
# a5={"name":"张三","age":18}
# print(type(a1))
# print(type(a2))
# print(type(a3))
# print(type(a4))
# print(type(a5))

# num1 = "100"
# num2 = "1.99"
# # print(type(int(num1)))
# # print(type(float(num2)))
# print(type(float(num1)))

# info = 12345
# # print(type(str(info)))
# info1 = [11, "aa", True, 1.88]
# # print(type(str(info1)))
# # print(type(tuple(info1)))
# # 转换为集合（集合中元素不能重复：可以去重）
# info2 = [11, 22, 33, 11, 11, 11, 33, 44]
# # print(set(info2))
# # print(type(set(info2)))
#
# name = "小明"
# age = 18
# height =1.88
# # print("{}今年{}岁了，他的身高是{}米".format(name,age,height))
# # print("{0}今年{1}岁了，他的身高是{2}米".format(name,age,height))
#
# name = "小明"
# age = 18
# height = 1.88
# # print(f"{name}今年{age}岁了，他的身高是{height}米")
# # print(f"{name}明年就{age+1}岁了")
#
# name = "小明"
# # age = int(input("请输入年龄："))
# # print(f"{name}同学的年龄是：{age}")
# # print(f"{name}同学明年的年龄是：{age+1}")
#
# num1 = 10
# num2 = 20
# # print(f"求和结果：{num1 + num2}") # 30
# # print(f"求差结果：{num1 - num2}") # ‐10
# # print(f"求乘结果：{num1 * num2}") # 200
# # print(f"求除结果：{num1 / num2}") # 0.5
# # print(f"求商结果：{num1 // num2}") # 0
# # print(f"求余结果：{num1 % num2}") # 10
#
# # 求余数常常运用奇偶数判断
# # print(3 % 2 == 0)
# # # 幂运算：10的3次方
# # print(10 ** 3)
# # # 特殊的求和: 字符串和字符串求和 ‐‐ > 字符串拼接
# # print("10" + "20")
# # # 特殊的乘法：字符串和数字相乘 ‐‐ > 字符串重复多少次
# # print("10" * 3)
#
# num1 = 10
# num2 = 20
# # print(f"{num1 == num2}") # False
# # print(f"{num1 != num2}") # True
# # print(f"{num1 > num2}") # False
# # print(f"{num1 < num2}") # True
# # print(f"{num1 >= num2}") # False
# # print(f"{num1 <= num2}") # True
# # print(10 == "10")
# # 数字和字符串比较结果一定是False
#
# #定义两个数字
# num1 = 10
# num2 = 20
# # 赋值运算并查看结果
# num1 += num2 # 相当于 num1 = num1 + num2
# # print("num1 =", num1) # 此时：num1 = 30
# # num1 -= num2 # 相当于 num1 = num1 ‐ num2
# # print("num1 =", num1) # 此时：num1 = 10
# # num1 *= num2 # 相当于 num1 = num1 * num2
# # print("num1 =", num1) # 此时：num1 = 200
# # num1 /= num2 # 相当于 num1 = num1 / num2
# # print("num1 =", num1) # 此时：num1 = 10.0
# # num1 %= num2 # 相当于num1=num1%num2
# # print("num1=",num1) #此时：num1=10
#
# 综合案例
# 需求：
# 提示用户输入用户姓名，并保存到变量中
# 提示用户输入用户年龄，保存到变量中，并转换成整数
# 提示用户输入用户身高，保存到变量中，并转换成浮点数
# 在控制台输出用户姓名、年龄、身高对应变量的数据类型
# 按照以下格式输出用户信息：“姓名:xxx 年龄:xxx 身高:xxx”
# 在控制台输出该用户5年之后的年龄，格式：“张三 5 年之后的年龄是 25”
# 在控制台输出该用户现在是否成年，格式：“张三是否成年：True”
# # 1.输入用户姓名、年龄、身高
# name = input("请输入姓名：")
# age = int(input("请输入年龄："))
# height = float(input("请输入身高："))
# # 2. 输出变量的数据类型
# print("姓名类型：", type(name))
# print("年龄类型：", type(age))
# print("身高类型：", type(height))
# # 直接输出用户信息
# print(f"姓名：{name} 年龄：{age} 身高：{height} ")
# # 输出5年后的年龄
# print(f"{name}5年后的年龄是：{age + 5}")
# # 输出是否成年：年龄和18岁进行比较 ‐‐‐> 结果是布尔值
# print(f"{name}是否成年：{age >= 18}")

# 定义变量
# age = 18
# if age >=18:
#     print("进入网吧上网~~~~")
#     print("猜猜我什么时候开始执行")
import random

# 结论
# age = int(input("请输入你的年龄："))
# #判断年龄
# if age >=18:
#     print("高姐网吧欢迎您")
# else:
#     print("未成年不允许进入网吧！")

# age =18
# # if 0 < age <100:
# if age > 0 and age < 100:
#     print("请输入正确")
# else:
#     print("输入错误！")

# #or
# #1、定义变量
# python_score = 80
# c_score = 30
# if python_score >= 60 or c_score >= 60:
#     print("成绩符合")

# #not
# age =19
# if not (age < 18):
#     print("已成年")
# else:
#     print("未成年")
#
# #not 构成条件
# # 定义变量
# #定义变量
#
# employer = True  #假设已经固定值（False /True)
# #if not employer:
# if not (employer is False):
#     print("本公司员工")
# else:
#     print("非本公司员工")

#if嵌套
# score = int(input("请输入分数："))
# if score >= 90:
#     print("优")
# elif 80 <= score < 90:
#     print("良")
# elif 70 <= score < 80:
#     print("中")
# elif 60 <= score < 70:
#     print("差")
# else:
#     print("不及格")

# has_ticket = int(input("请输入是否有票（0/非0）："))     #0没票
# if has_ticket:
#     knife_length = int(input("请确认票长度："))
#     if knife_length >=20:
#         print("不允许上车")
#     else:
#         print("安检通过，允许上车")
# else:
#     print("不允许上车")

# import random
#
# num = random.randint(10,20)  #开始到结束的范围
# print(num)

# #石头剪刀布的游戏
# import random
# print("======游戏开始======")
# # 定义变量
# # 人，玩家
# player = int(input("请输入你的出拳(数字1【石头】/2【剪刀】/3【布】)："))
# #电脑
# computer = random.randint(1,3)
# print("电脑出拳的是：",computer)
# #判断
# if (player == 1 and computer == 2) or (player == 2 and computer == 3) or (player == 3 and computer == 1):
#  print("人赢了！")
# elif player == computer:
#    print("平局")
# else:
#      print("人输了")

# #道歉100次，内容为："哈哈哈，大笨蛋"
# num = 1
# while num <= 100:
#     print("哈哈哈，大笨蛋！")
#     num += 1   #num = num + 1

# # 总结
# # 设置计数器
# num = 0
# # 结果
# result = 0
# while num <= 100:
#     result += num    # result = result + num
#     num += 1    # num = num + 1
# print(f"0~100累积求和的结果为：{result}")

# # 定义计数器
# num = 1
# while num <= 5:
#     print(f"吃第一{num}个苹果")
#     if num == 3:
#         print("吃饱了，吃不下了")
#         break     # 跳出整个循环，当满足某个条件时提前结束循环
#     num += 1

# # 定义计数器
# num = 1
# while num <= 5:
#     print(f"吃第一{num}个苹果")
#     if num == 3:
#         print("吃饱了，吃不下了")
#         print("放坏了，不能吃了")
#         continue        # 无限循环
#     num += 1

# # range函数
# # for i in range(0,10):
# # for i in range(1,11):
# for i in range(10):
#     print("我错了我错了")
#
# # 需求for循环：计算0~100之间所有偶数的累积加
# # 结果
# result = 0
# for i in range(1,101):
#     if i % 2 == 0:
#         result += i
# print(result)
# 882173191


# 10\22
# # 定义变量
# info1 = "D:\tools\noco"
# info2 = r"D:\tools\noco"
# info3 = "D:\\tools\\noco"
# info4 = '张杰说："你很棒"'
# print("")

# info = "abcdrfg"
# print(info[-1])
# # 位置字母e在哪
# print(info.find("e"))
# # 位置字母k在哪
# print(info.find("k"))

# # 定义字符串
# info = "我还记得你你看看你"
# # 使用字符串（替换）
# info1 = info.replace("格式的","单位A")
# print(info1)
# print(info)

# info = ['Python','Java','PHP']
# num = [11,22,33]
# # 连接
# info1 = " and ".join(info)
# print(info1)
# print(type(info1))
# # print("_".join(num))

# sql语句
# sql = "SelECt * from students where id = 001";
# print(sql.split())
# # 对应容器中元素的获取直接用for循环即可
# for i in sql.split():
#     print(i)

# str = [1,2,3,4,5]
# for i in str:
#     print(i)
#     print(str)

# # 清除字符串两头的空格
# phone = " 18878117571 "
# print(phone)
# print(phone.strip())

# #大小转换
# sql = "SelECt * from students where id = 001";
# if "select" in sql.lower():
#     print(sql.lower())

# # 课堂案例
# # 1.用户输入手机号，密码，验证码
# phone1 = input("请输入手机号：")
# # 2.手机号，密码，验证码去掉两端空格
# phone = phone1.strip()
# password = input("请输入密码：").strip()
# code = input("请输入验证码：").strip()
# # 3.判断是否为空
# if phone == "":
#     print("手机号不能为空")
# elif password == "":
#     print("密码不能为空")
# elif code == "":
#     print("验证码不能为空")
# # 4.判断手机号格式是否正确(类型，长度len)
# if phone.isdigit() and len(phone) == 11:
#     print("手机号格式正确")
# else:
#     print("手机号格式错误")
# # 5.判断验证码格式是否正确
# if code.lower() == "8888":
#     print("验证码正确")
# else:
#     print("验证码错误")
# # 6.判断手机号、密码、验证码是否正确
# if phone == "18878117571":
#     print("手机号正确")
#     if password == "123456":
#         print("密码正确")
#         if code.lower() == "8888":
#             print("登录成功")
#         else:
#             print("验证码错误")
# else:
#     print("手机号不存在")

# # 定义类实例化
# list = []
# print(list)
# list.insert(0,"python")
# print(list)
#
# list2 = ["web自动化","接口自动化","测试基础"]
# print(list2)
# # list2.insert(3,"python")
# list2.insert(-1,"python")
# print(list2)
# list2.append("c")
# print(list2)

# # 末尾添加
# val_list = ["web自动化","接口自动化","测试基础"]
# # 添加元素（末尾添加：APP自动化）
# val_list.append("APP自动化")
# # 查看原来列表
# print(val_list)
# # 增加数字元素
# val_list.append(11)
# print(val_list)
# list列表的索引位置添加
# val_list = ["web自动化","接口自动化","测试基础"]
# val_list.insert(1,"APP自动化")
# print(val_list)
# val_list.insert(6,"Java")
# print(val_list)

# # 列表的合并
# info1 = [1,2,3]
# info2 = [4,5,6]
# # 合并
# # info1.extend(info2)
# info2.extend(info1)
# #查看
# # print(info1)
# print(info2)

# # 列表元素的删除-指定索引位置
# val_list = ["web自动化","UI自动化","接口自动化","测试基础","Java"]
# # 删除下标为2
# val_list.pop(2)
# print(val_list)
# # 删除下标为空的
# val_list.pop()
# print(val_list)
# # 删除下标为7
# val_list.pop(7)
# print(val_list)

# # 指定数据删除
# val_list = ["web自动化","UI自动化","接口自动化","测试基础","Java","软件工程"]
# val_list.remove("Java")
# print(val_list)    # 查看原有列表

# # 删除重复出现的数据
# val_list = ["web自动化", "软件二", "接口自动化", "测试基础", "Java", "软件二", "UI自动化"]
# new_list = []
# for item in val_list:
#     if item != "软件二":
#         new_list.append(item)
# val_list = new_list
# print(val_list)

# # 元素倒置（反转）
# info = [8, 100, 30, 10, 40, 2]
# # 反转
# info.reverse()
# # 查看原有列表
# print(info) # [2, 40, 10, 30, 100, 8]

# # 大小排列
# info = [8, 100, 30, 10, 40, 2]
# # 从小到大排序
# info.sort()
# info.sort(reverse=False)
# # 查看原有列表
# print(info)
# # 从大到小排序
# info.sort(reverse=True)
# print(info)

# # 列表的嵌套元素获取：列表中的元素还是列表
# # 列表中的元素还是列表：列表嵌套
# student_list = [["张三", "18", "功能测试"], ["李四", "20", "自动化测试"], ["王五", "22",
# ["python", "java"]]]
# # 获取指定的元素
# # 查找元素18，如何查找？
# print(student_list[0])
# aa = student_list[0] # ['张三', '18', '功能测试']
# print(aa[1]) # 18
# # 合并起来
# print(student_list[0][1]) # 18
# # 查找李四
# print(student_list[1][0]) # 李四
# # 查找java
# print(student_list[2][2][1]) # java

# # 列表的嵌套：列表中的元素还是列表
# # 登录页面为例
# # 需求：分别使用不同的数据（包括手机号、密码、验证码）进行登录验证
# # 结果：账号或密码错误；验证码错误；登录成功
# # 定义非空列表(把每种测试结果的数据放在一起)
# login_data = [
# ["13488888888", "123456", "8888"],
# ["13488888888", "666666", "8888"],
# ["13488888880", "123456", "8888"],
# ["13488888888", "123456", "0000"]
# ]
# # 遍历
# for i in login_data:
# # print(i) # 每一个中括号的数据 ，i = ["13488888888", "123456", "8888"]
# # 判断手机号和密码
# if i[0] == "13488888888" and i[1] == "123456":
# # 判断验证码
# if i[2] == "8888":
# print("登录成功")
# else:
# print("验证码错误")
# else:
# print("用户名或密码错误")


# # 定义空元组
# info = ()
# info1 = tuple()
# print(info)
# print(info1)
# # 非空
# info2 = (11,22,33,44)
# print(info2)
# info3 = ("55",)
# print(type(info3))
# # 不写括号
# info4 =1,2,3,4
# print(type(info4))

# # 元组元素查询：索引
# info =(11,"aaa",1.88)
# print(info[2])
# print(info[4])

# # 元组元素查询：元素统计
# info = (1,2,3,2)
# print(info.count(2))  #出现2次

# # 案例
# num1 = 100
# num2 = 200
# num1,num2 = num2, num1
# print("此时num1的值为：", num1)
# print("此时num2的值为：", num2)

# # 字典
# # 定义空字典
# info = {}
# info1 = dict()
# print(type(info), type(info1))
# print(info)
# # 非空字典
# info2 = {"name": "张三", "age": 22, "height": 1.88}
# print(info2)
# print(type(info2))

# # 字典的使用
# # 定义非空字典
# info = {"name": "张三"}
# # 将张三修改为李四
# info["name"] = "李四"
# # 查看原有字典
# print(info) # {'name': '李四'}
# # 增加年龄为22岁
# info["age"] = 22
# # 查看原有字典
# print(info) # {'name': '李四', 'age': 22}

# # 字典删除值
# # 定义字典
# info = {'name': '李四', 'age': 22}
# # 删除年龄22
# info.pop("age")
# # 查看原来字典
# print(info)
# # 删除性别
# # info.pop("sex") # KeyError: 'sex'

# 字典中取值
# # 定义非空字典
# info = {
# "name": "tom",
# "age": 18,
# "gender": "男",
# "hobby": {"read": "小说", "sport": ["篮球", "足球"]}
# }
# # 查询年龄
# # a1 = info["age"]
# # print(a1)
# print(info["age"])
# # a2 = info.get("age")
# # print(a2)
# print(info.get("age"))
# # 查询键aa的值
# # print(info["aa"]) # 代码报错：KeyError: 'aa' 键aa不存在
# print(info.get("aa")) # None 表示aa键不存在
# # 思考：如何获取值："足球"
# # a1 = info["hobby"]
# # print(a1) # {'read': '小说', 'sport': ['篮球', '足球']}
# # print(a1["sport"]) # ['篮球', '足球']
# # print(a1["sport"][1])
# # 组合:从外部一层一层获取递进
# print(info["hobby"]["sport"][1])
# print(info.get("hobby").get("sport")[1])

# # 字典的合并/新增
# # 定义字典1
# dict1 = {"name": "张三", "age": 18}
# # 定义字典2
# dict2 = {"height": 1.88}
# # 将字典2合并到字典1
# dict1.update(dict2)
# print(dict1)
#
# # 字典的遍历
# # 定义非空字典
# info = {
# "name": "tom",
# "age": 18,
# "gender": "男"
# }
# # 遍历获取字典中所有键
# for i in info.keys():
#     print(f"字典的键是：{i}")
# # 遍历获取字典中所有值
# for i in info.values():
#     print(f"字典的值是：{i}")
# # 遍历获取字典的键和值
# for k, v in info.items():
#     print(f"{k} = {v}")

# # 集合
# # 1.定义空集合
# info = set()
# print(info)
# # 2.集合中添加元素："a"
# info.add("a")
# info.add("b")
# print(info)

# 切片操作
# # 定义非空字符串
# var = "abcdeabdcdf"
# # 3.打印非重复的元素
# print(set(var))
# tmp = list(set(var))
# tmp.sort()
# print(tmp)
# print("".join(tmp))
# name = "abcdefgh"
# print(name[2:5])
# print(name[2:5:1])
# print(name[-6:-3])
# print(name[-6:-3:1])
# # 获取drfgh字符
# print(name[3:8])
# print(name[3:])
# print(name[-5:])
# # 获取ace字符
# print(name[0:5:2])
# print(name[:5:2])
# # 获取hgfedcba
# print(name[::-1])

# # 定义非空字符串
# info = "abcdefgh"
# info1 = "Hello Python"
# # 统计字符元素个数（长度）
# print(len(info))
# print(len(info1))
# # 定义非空列表
# info2 = [11, "aa", 1.88, (1, 2, 3), ["aa", "bb"]]
# print(len(info2))
# # 定义非空元组
# info3 = (11, "aa", 1.88)
# print(len(info3))
# # 定义非空字典
# info4 = {"name": "tom", "age": 18, "gender": "男"}
# print(len(info4))

# # 清空序列
# info2 = [11, "aa", 1.88, (1, 2, 3), ["aa", "bb"]]
# # 清空列表数据
# info2.clear()
# # 查看原有列表
# print(info2)
# info4 = {"name": "tom", "age": 18, "gender": "男"}
# # 清空字典数据
# info4.clear()
# # 查看原有字典
# print(info4)

# # 综合案例
# # 定义变量：列表
# login_data1 = [
# ["13800000001", "123456", "8888", "登录成功"],
# ["13800000001", "1234", "8888", "密码错误"],
# ["13800000001", "123456", "0000", "验证码错误"]
# ]
# # 定义变量：元组
# login_data2 = (
# ("13800000001", "123456", "8888", "登录成功"),
# ("13800000001", "1234", "8888", "密码错误"),
# ("13800000001", "123456", "0000", "验证码错误")
# )
# # 定义变量：列表元组
# login_data3 = [
# ("13800000001", "123456", "8888", "登录成功"),
# ("13800000001", "1234", "8888", "密码错误"),
# ("13800000001", "123456", "0000", "验证码错误")
# ]
# # 定义变量：列表字典
# login_data4 = [
# {"username": "13800000001", "password": "123456", "code": "8888", "result": "登录成功"},
# {"username": "13800000001", "password": "666666", "code": "8888", "result": "密码错误"},
# {"username": "13800000001", "password": "123456", "code": "0000", "result": "验证码错误"}
# ]
# # 遍历数据3
# for i in login_data3:
#     # print(i)
#     print(f"用户名：{i[0]} 密码：{i[1]} 验证码：{i[2]} 期望结果：{i[3]}")
# # 遍历数据4
# for i in login_data4:
#     # print(i)
#     print(f"用户名：{i.get('username')} 密码：{i.get('password')} "
#           f"验证码：{i.get('code')} 期望结果：{i.get('result')}")
#     # print(f"用户名:{i['username']}")

# # 函数的定义和调用
# # 需求：
# # 有两个参数：手机号和密码
# # 手机号的测试数据有三个，密码的测试数据也有三个
# # 最后组装成元组列表类型的数据作为最终的测试数据: [(手机号1,密码1),(手机号2,密码2),...]
# # 总共需要几种场景的测试数据
# phone_list = ['13880001111', '13999992222', '150999933331']
# password_list = ['123456', '456def', 'aaaaaa']
#
#
#
# # # 元组列表类型的数据
# # # 定义空列表
# list = []
# # # 遍历手机号
# for i in phone_list:
#     # print(i)
#     for j in password_list:
#         # print(j)
#         # print(i,j)
#         tup = (i,j)
#         # print(tup)
#         list.append(tup)
#         # print(list)
# print(list)


# # 列表推导式：Python中构造列表数据的一种简洁方法
# # 语法1：[表达式 for 变量 in 可迭代对象]
# # 案例：从1~10中获取每个整数的平方，保存到列表中
# # 方式1：for循环
# res1 = []
# for i in range(1,11):
#     res1.append(i**2)
# print(res1)

# # 方式2：列表推导式
# res2 = [i**2 for i in range(1,11)]
# print(res2)

# # 语法2：[表达式 for 变量 in 可迭代对象 if 条件判断]
# # 案例：从1~10中获取每个整数偶数的平方，保存到列表中
# res3 = [i ** 2 for i in range(1, 11) if i % 2 == 0]
# print(res3)

# # 语法3：[表达式 for 变量 in 可迭代对象 for 变量 in 可迭代对象]
# result1 = [(i, j) for i in phone_list for j in password_list]
# print(result1)




# 定义函数demo
# def demo():
#     """我是注释"""
#     print("我是函数")

# # 调用函数
# demo()

# def demo(a,b):
#     """我是注释"""
#     print("我是函数")

# # 调用函数
# demo()

# # 案例演示
# # 定义字典(非空)元素的列表
# login_data = [
# {"username": "13488888888", "password": "123456"},
# {"username": "", "password": "123456"},
# {"username": "13800000001", "password": ""},
# {"username": "13800000001", "password": "123"}
# ]
#
# # 思路：数据和业务分离的思路
# # 1.先实现业务功能（函数）
# def login(phone, pwd):
#     """
#     登录判断函数
#     :param phone: 手机号
#     :param pwd: 密码
#     :return: 无
#     """
#     if phone == "13488888888" and pwd == "123456":
#         print("登录成功")
#     else:
#         print("登录失败")
#
# # 调用函数
# login("13488888888","123456")
#
# num = 1 # 计数器
# for i in login_data:
#    # 获取账号密码
#    phone = i.get("username")
#    pwd = i.get("password")
#    print(f"第{num}次测试")
#    # 调用函数
#    login(phone, pwd)
#    num += 1 # 调用一次计数器增1

# 案例
# 定义函数
# def login(phone):
#     """
#     模拟登录
#     :param phone: 验证手机号
#     :return: 返回账号的结果
#     """
#     # 模拟登录
#     if phone == "13488888888":
#         return "账号正确" # 判断之后的结果返回给调用者
#     else:
#         return "账号错误"
# # 调用函数
# # a = login("13800000001") # 返回的结果找变量接收
# # print(a) # 想看结果就直接打印出来
# # print(login("13488888888"))
# # 调用函数断言结果
# assert "账号错误" == login("13800000001") # 预期结果 == 实际结果
# assert "正确" in login("13488888888") # 预期结果 in 实际结果

# 需求：设计一个函数用于获取两个数中的较大数，数据来自于函数的参数，最后返回较大值
# 1.定义函数
# def get_max(num1, num2):
#     """获取较大值函数"""
#     # 有两个数字：直接通过参数传递
#     # 判断大小关系
#     if num1 > num2: # num1大于num2 返回num1
#         # 返回较大值
#         return num1
#     else: # num1小于等于num2 返回num2
#          return num2
# # 2.调用函数
# num = get_max(10, 20)
# print(num)
# # print(get_max(10, 20))

